package Sort;

import java.util.Scanner;

/**
 * @author Liangyaoyun
 */
public class Simple {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int n = scanner.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; i++) {
            arr[i] = scanner.nextInt();
        }
        int[] sortedArr = radixSort(arr, n);
        String[] nums = new String[sortedArr.length];
        for (int i = 0; i < sortedArr.length; i++) {
            nums[i] = sortedArr[i] + "";
            if (nums[i].length()<n){
                switch (n-nums[i].length()){
                    case 0: break;
                    case 1:
                        nums[i]="0"+nums[i];
                        break;
                    case 2:
                        nums[i]="00"+nums[i];
                        break;
                    case 3:
                        nums[i]="000"+nums[i];
                        break;
                    case 4:
                        nums[i]="0000"+nums[i];
                        break;
                    case 5:
                        nums[i]="00000"+nums[i];
                        break;
                    case 6:
                        nums[i]="000000"+nums[i];
                        break;
                }
            }
/*            if (nums[i].length() == 1) {
                nums[i] = "00" + nums[i];
            } else if (nums[i].length() == 2) {
                nums[i] = "0" + nums[i];
            }*/
        }
        for (int i = 0; i < nums.length; i++) {
            if (i == nums.length - 1) {
                System.out.println(nums[i]);
            } else {
                System.out.print(nums[i] + " ");
            }
        }
    }

    public static int[] radixSort(int[] arr, int n) {
        int maxVal = getMaxValue(arr, n);
        int maxDigit = getMaxDigit(maxVal, n);
        int[] bucket = new int[10];
        int[] sortedArr = new int[arr.length];
        for (int i = 0; i < maxDigit; i++) {
            for (int j = 0; j < arr.length; j++) {
                int digit = getDigit(arr[j], i, n);
                bucket[digit]++;
            }
            for (int j = 1; j < bucket.length; j++) {
                bucket[j] += bucket[j - 1];
            }
            for (int j = arr.length - 1; j >= 0; j--) {
                int digit = getDigit(arr[j], i, n);
                sortedArr[bucket[digit] - 1] = arr[j];
                bucket[digit]--;
            }
        }
        return sortedArr;
    }

    private static int getMaxValue(int[] arr, int n) {
        int maxVal = arr[0];
        for (int i : arr) {
            if (i > maxVal) {
                maxVal = i;
            }
        }
        return maxVal;
    }

    private static int getMaxDigit(int maxVal, int n) {
        int maxDigit = 0;
        while (maxVal > 0) {
            maxVal /= 10;
            maxDigit++;
        }
        return maxDigit - n + 1;
    }

    private static int getDigit(int num, int index, int n) {
        return (num / ((int) Math.pow(10, index))) % 10;
    }
}
